<template>
  <div class="super-agent">
    <ChatInterface
      title="超级智能体"
      :messages="superAgentStore.messages"
      :loading="superAgentStore.loading"
      :error="superAgentStore.error"
      empty-state-message="我可以帮您完成各种任务，请告诉我您需要什么帮助！"
      @send-message="handleSendMessage"
      @clear-chat="handleClearChat"
    />
  </div>
</template>

<script setup>
import { onMounted } from 'vue'
import { useSuperAgentStore } from '../stores/superAgentStore'
import ChatInterface from '../components/ChatInterface.vue'

const superAgentStore = useSuperAgentStore()

const handleSendMessage = async (message) => {
  await superAgentStore.sendMessage(message)
}

const handleClearChat = () => {
  superAgentStore.clearMessages()
}

// 组件挂载时显示欢迎消息
onMounted(() => {
  if (superAgentStore.messages.length === 0) {
    superAgentStore.messages.push({
      role: 'assistant',
      content: '您好！我是超级智能体，可以帮助您完成各种任务。无论是编程开发、数据分析、文案创作，还是其他专业领域的问题，我都能为您提供专业的解决方案。请告诉我您需要什么帮助？',
      timestamp: new Date().toISOString()
    })
  }
})
</script>

<style scoped>
.super-agent {
  height: 100vh;
  background-color: #f9f9f9;
}
</style>